package demoMod.invincibleOne.skins;

import com.badlogic.gdx.graphics.Texture;
import com.megacrit.cardcrawl.actions.animations.TalkAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CharacterStrings;
import com.megacrit.cardcrawl.localization.UIStrings;
import com.megacrit.cardcrawl.rooms.AbstractRoom;
import demoMod.invincibleOne.InvincibleOneMod;
import demoMod.invincibleOne.cards.invincible.*;
import demoMod.invincibleOne.patches.CharacterSelectPatch;

import java.util.ArrayList;

public abstract class Skin {
    private static final UIStrings uiStrings = CardCrawlGame.languagePack.getUIString(InvincibleOneMod.makeID("Reskin"));
    private static final String[] TEXT = uiStrings.TEXT;
    private static final UIStrings extraStrings = CardCrawlGame.languagePack.getUIString(InvincibleOneMod.makeID("ReskinExtra"));
    private static final String[] EXTRA = extraStrings.TEXT;
    private static final CharacterStrings characterStrings =
            CardCrawlGame.languagePack.getCharacterString("InvincibleOne");
    private static final String[] DESC = characterStrings.TEXT;

    public Texture portrait;
    public Texture[] deathCG = {null, null, null};
    public Texture sprite;
    public Texture shoulder1;
    public Texture shoulder2;
    public String skinID;
    public String name;
    public String extraDesc;
    public String desc;
    public String trashTalkPrefix;
    // 是否使用骨骼。
    public String atlasPath;
    public String atlasIdle;
    public float atlasScale;
    public boolean isPrimeForm;
    public static ArrayList<Skin> skins = new ArrayList<>();

    public Skin(int index) {
        this(index, "");
    }

    public Skin(int index, String atlas) {
        skinID = String.valueOf(index-1);
        name = TEXT[1 + index];
        extraDesc = EXTRA[index - 1];
        desc = DESC[index - 1];
        this.atlasPath = atlas;
        atlasScale = 1.0F;
        this.trashTalkPrefix = InvincibleOneMod.makeID("TrashTalk");
    }

    public Skin(String skinID, String name, String desc, String extraDesc, String atlasPath, String trashTalkPrefix) {
        this.skinID = skinID;
        this.name = name;
        this.desc = desc;
        this.extraDesc = extraDesc;
        this.atlasPath = atlasPath;
        atlasScale = 1.0F;
        this.trashTalkPrefix = trashTalkPrefix.isEmpty() ? InvincibleOneMod.makeID("TrashTalk") : trashTalkPrefix;
    }

    public abstract void load();

    public static Skin skinNow() {
        return skins.get(CharacterSelectPatch.skinIndex[CardCrawlGame.saveSlot]);
    }
    public void onVictory(){}
    public abstract void onGameStart();
    public void atTurnStart(){}
    // 返回复活时的生命百分比
    public float onReborn(){return 0.3F;}
    public int onAttackedToChangeDamage(DamageInfo dmg, int amount){return amount;}
    public ArrayList<String> getStartingDeck() {
        ArrayList<String> ret = new ArrayList<>();
        ret.add(Anarchy.ID);
        ret.add(Anarchy.ID);
        ret.add(Anarchy.ID);
        ret.add(Anarchy.ID);
        ret.add(Flawless.ID);
        ret.add(Flawless.ID);
        ret.add(Flawless.ID);
        ret.add(Flawless.ID);
        ret.add(Flawless.ID);
        ret.add(NoOneLives.ID);
        ret.add(NoOneLives.ID);
        ret.add(NoOneLives.ID);
        ret.add(NoOneLives.ID);
        ret.add(NoOneLives.ID);
        ret.add(Brutal.ID);
        ret.add(Brutal.ID);
        ret.add(OutOfThinAir.ID);
        if (InvincibleOneMod.seriousLevel[CardCrawlGame.saveSlot] >= 6) {
            ret.add(OutOfThinAir.ID);
        }
        return ret;
    }
    public ArrayList<AbstractCard> getStartingCards() {
        ArrayList<AbstractCard> ret = new ArrayList<>();
        ret.add(new Anarchy());
        ret.add(new Flawless());
        ret.add(new NoOneLives());
        ret.add(new Brutal());
        ret.add(new OutOfThinAir());
        return ret;
    }
    public void onEnterRoom(AbstractRoom room){}

    // 垃圾话
    public static String[] TrashTalkGameStart1;
    public static String[] TrashTalkGameStart2;
    public static String[] TrashTalkGameStart3;
    public static String[] TrashTalkGameStart4;
    public static String[] TrashTalkGameStart5;
    public static String[] TrashTalkAct2_1;
    public static String[] TrashTalkAct2_2;
    public static String[] TrashTalkAct3;
    public static String[] TrashTalkFightTheHeart;
    public static String[] TrashTalkFightTheHeartProvoked;
    public static String[] TrashTalkDamage5;
    public static String[] TrashTalkDamage5Provoked;
    public static String[] TrashTalkDamage15;
    public static String[] TrashTalkSecondWind;
    public static String[] TrashTalkSecondWindProvoked;
    public static String[] TrashTalkKillAll;

    public static boolean trashTalked = false;
    public static void TrashTalk(String text) {
        TrashTalk(text, false);
    }
    // 每场战斗最多只会喷一次垃圾话。
    public static void TrashTalk(String text, boolean noLimit) {
        if (!trashTalked || noLimit) {
            trashTalked = true;
            AbstractDungeon.actionManager.addToBottom(new TalkAction(true, text, 1.0F, 2.0F));
        }
    }
}
